{% extends "base.html" %}

{% block head %}
    <link rel="stylesheet" href="{{ theme_asset(request, 'js/remodal/remodal.css') }}">
    <link rel="stylesheet" href="{{ theme_asset(request, 'js/remodal/remodal-default-theme.css') }}">
    <script src="{{ theme_asset(request, 'js/remodal/remodal.js') }}"></script>
    <script src="/static/js/jquery.register_form.js"></script>

    {% if (config.cf_cert_use and (config.cf_cert_simple or config.cf_cert_ipin or config.cf_cert_hp)) %}
    <script src="/static/js/certify.js"></script>
    {% endif %}
{% endblock head %}

{% block title %}会员的条款和条款{% endblock title %}
{% block subtitle %}会员的条款和条款{% endblock subtitle %}

{% block content %}
<div class="social_register">

    <form name="fregisterform" id="fregisterform" action="{{ form.action_url }}"
          onsubmit="return fregisterform_submit(this);" method="POST" autocomplete="off">

        <p>
            <i class="fa fa-check-circle" aria-hidden="true"></i>
            您必须同意会员条款以及个人信息收集和使用的内容。.
        </p>

        <section id="fregister_term">
            <h2>会员的条款和条款</h2>
            <textarea readonly>{{ config.cf_stipulation }}</textarea>
            <fieldset class="fregister_agree">
                <input type="checkbox" name="agree" value="1" id="agree11" class="selec_chk">
                <label for="agree11"><span></span><b class="blind">我同意会员资格条款的内容.</b></label>
            </fieldset>
        </section>

        <section id="fregister_private">
            <h2>拼贴和个人信息的使用</h2>
            <div>
                <table>
                    <caption class="blind">拼贴和个人信息的使用</caption>
                    <thead>
                    <tr>
                        <th>目的</th>
                        <th>项目</th>
                        <th>保留期</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>用户识别和识别</td>
                        <td>Idie, 姓名, 密码 {% if config.cf_cert_use %} 出生日期, 移动电话号码(仅当您进行身份验证时, 不包括ipin),
                            加密的个人识别标志(CI) {% endif %}
                        </td>
                        <td>直到成员退出</td>
                    </tr>
                    <tr>
                        <td>关于使用客户服务的通知,<br>CS用于响应的用户标识</td>
                        <td>联系人 (电子邮件, 移动电话号码)</td>
                        <td>直到成员退出</td>
                    </tr>
                    </tbody>
                </table>
            </div>

            <fieldset class="fregister_agree">
                <input type="checkbox" name="agree2" value="1" id="agree21" class="selec_chk">
                <label for="agree21"><span></span><b class="blind">我同意个人信息收集和使用的内容.</b></label>
            </fieldset>
        </section>

        <div id="fregister_chkall" class="chk_all fregister_agree">
            <input type="checkbox" name="chk_all" id="chk_all" class="selec_chk">
            <label for="chk_all"><span></span>所有人都同意会员资格条款</label>
        </div>
        <!-- } 会员条款协议终止 -->

        <!-- 开始新加入 -->
        <input type="hidden" name="action" value="is_register">
        <input type="hidden" name="cert_type" value="{{ request.state.login_member.mb_certify }}">
        <input type="hidden" name="cert_no" value="">
        <input type="hidden" name="mb_id" value="{{ form.social_member_id }}" id="reg_mb_id">
        {% if config.cf_cert_use %}{#  标识 #}
            {% if member_name %}
            <input type="hidden" id="reg_mb_name" name="mb_name" value="{{member_name}}">
            {% else %}
            <input type="hidden" id="reg_mb_name" name="mb_name" value="{{member_nick}}">
            {% endif %}
        {% endif %}
        {% if config.cf_use_hp or (config.cf_cert_use and (config.cf_cert_hp or config.cf_cert_simple)) %}
        <input type="hidden" name="mb_hp" value="{{ user_phone }}" id="reg_mb_hp">
        {% if config.cf_cert_use and (config.cf_cert_hp or config.cf_cert_simple) %}
        <input type="hidden" name="old_mb_hp" value="{{ user_phone }}">
        {% endif %}
        {% endif %}

        <div id="register_form" class="form_01">
            <div class="tbl_frm01 tbl_wrap register_form_inner">
                <h2>个人信息输入</h2>
                <ul>
                    <li>
                        {% if config.cf_cert_use %}
                        {% if config.cf_cert_simple %}
                        <button type="button" id="win_sa_kakao_cert" class="btn_frmline win_sa_cert" data-type="">简单身份验证
                        </button>
                        {% endif %}
                        {% if config.cf_cert_hp %}
                        <button type="button" id="win_hp_cert" class="btn_frmline">检查您的手机</button>
                        {% endif %}
                        {% if config.cf_cert_ipin %}
                        <button type="button" id="win_ipin_cert" class="btn_frmline">Ipin自检</button>
                        {% endif %}
                        <span class="cert_req">(必不可少的)</span>
                        <noscript>您必须能够使用yvabas来验证您自己的。.</noscript>
                        {% endif %}
                    </li>

                    <li>
                        <label for="reg_mb_nick">
                            昵称 (必不可少的)
                            <button type="button" class="tooltip_icon">
                                <i class="fa fa-regular fa-question-circle" aria-hidden="true"></i>
                                <span class="blind">见说明</span>
                            </button>
                            <span class="tooltip">不带空格的朝鲜文,英语,只能输入数字 (朝鲜文2成, 英语4超过)<br> 如果你改变你的昵称， 
                                {{ config.cf_nick_modify }} 天内无法更改.
                            </span>
                        </label>

                        <input type="hidden" name="mb_nick_default"
                               value="{{ form.social_nickname }}">
                        <input type="text" name="mb_nick"
                               value="{{ form.social_nickname }}" id="reg_mb_nick"
                               required class="frm_input required nospace full_input" size="10" maxlength="20"
                               placeholder="昵称">
                               placeholder="닉네임">
                        <span id="msg_mb_nick"></span>
                    </li>
                    <li>
                        <label for="reg_mb_email">E-mail (必不可少的)
                            {% if config.cf_use_email_certify %}
                            <button type="button" class="tooltip_icon">
                                <i class="fa fa-regular fa-question-circle" aria-hidden="true"></i>
                                <span class="blind">见说明</span>
                            </button>
                            <span class="tooltip">
                                    {% if is_register %}
                                        "E-mail 确认发送到的内容后，必须验证您的会员资格。."
                                    {% else %}
                                        "E-mail 如果您更改地址，则必须重新进行身份验证."
                                    {% endif %}
                                </span>
                            {% endif %}
                        </label>
                        <input type="text" name="mb_email" value="{{ form.social_email }}"
                               id="reg_mb_email"
                               {% if form.social_email and not form.is_exists_email %}
                               readonly
                               {% endif %}
                               required
                               class="frm_input email full_input required" size="70" maxlength="100"
                               placeholder="E-mail">
                        <div class="check">
                            {{ email_msg }}
                        </div>
                    </li>
                </ul>
            </div>
        </div>

        <div class="btn_confirm text-end">
            <a href="{{ request.base_url }}" class="btn_close">取消</a>
            <button type="submit" id="btn_submit" class="btn_submit" accesskey="s">
                {% if is_register %}成员资格{% else %}信息更正{% endif %}
            </button>
        </div>

    </form>

</div>


<!-- 现有帐户的连接 -->

<div class="member_connect">
    <p class="strong">你是现有会员。?</p>
    <button type="button" class="connect-opener btn-txt" data-remodal-target="modal">
        连接到现有帐户
        <i class="fa fa-angles-right"></i>
    </button>
</div>

<div id="sns-link-pnl" class="remodal" data-remodal-id="modal" role="dialog" 
     aria-labelledby="modal1Title" aria-describedby="modal1Desc">
    <button type="button" class="connect-close" data-remodal-action="close">
        <i class="fa fa-close"></i>
        <span class="txt">关闭</span>
    </button>
    <div class="connect-fg">
        <form method="post" action="{{ url_for('login') }}" onsubmit="return flogin_submit(this);">
            <input type="hidden" id="provider" name="provider" value="{{ provider_name }}">
            <!--            <input type="hidden" id="action" name="action" value="social_account_linking">-->

            <div class="connect-title">连接到现有帐户</div>

            <div class="connect-desc">
                在现有的Idie SNS 我们连接Idie.<br>
                之后 SNS 如果您使用Iddy登录，则可以使用现有的Iddy登录.
            </div>

            <div id="login_fs">
                <label for="login_id" class="login_id">Idie (必不可少的)</label>
                <span class="lg_id">
                    <input type="text" name="mb_id" id="login_id" class="frm_input required alnum_" size="20" maxLength="20">
                </span>
                <label for="login_pw" class="login_pw">密码 (必不可少的)</label>
                <span class="lg_pw">
                    <input type="password" name="mb_password" id="login_pw" class="frm_input required" size="20" maxLength="20">
                </span>
                <br>
                <input type="submit" value="要连接" class="login_submit btn_submit">
            </div>

        </form>
    </div>
</div>

<script>
    const cf_cert_use = "{{ config.cf_cert_use|default('0', true) }}"
    const cf_cert_simple = "{{config.cf_cert_simple|default('', true) }}"
    const cf_cert_hp = "{{ config.cf_cert_hp|default('', true) }}"
    const cf_cert_ipin = "{{ config.cf_cert_ipin|default('', true) }}"
    const cert_url = ""
    const cert_type = ""
    const is_register = "{{ is_register }}"
    
    $(function() {
        // 选择全部
        $("input[name=chk_all]").click(function() {
            if ($(this).prop('checked')) {
                $("input[name^=agree]").prop('checked', true);
            } else {
                $("input[name^=agree]").prop("checked", false);
            }
        });

        $("#reg_zip_find").css("display", "inline-block");
        const pageTypeParam = "pageType=register";

        //tooltip
        $(document).on("click", ".tooltip_icon", function(e) {
            $(this).next(".tooltip").fadeIn(400).css("display", "inline-block");
        }).on("mouseout", ".tooltip_icon", function(e) {
            $(this).next(".tooltip").fadeOut();
        });
    });

    // submit 最终形式检查
    function fregisterform_submit(f) {

        if (!f.agree.checked) {
            alert("您必须同意会员资格条款.");
            f.agree.focus();
            return false;
        }

        if (!f.agree2.checked) {
            alert("您必须同意个人信息收集和使用的内容，您可以加入.");
            f.agree2.focus();
            return false;
        }

        {% if (is_register == "" and config["cf_cert_use"] and config["cf_cert_req"]) %}
            // 检查您的身份
            if (f.cert_no.value == "") {
                alert("您需要确认您的会员资格。.");
                return false;
            }
        {% endif %}

        // Nicknname检查
        if (is_register || (f.mb_nick.defaultValue != f.mb_nick.value)) {
            const msg = reg_mb_nick_check();
            if (msg) {
                alert(msg);
                f.reg_mb_nick.select();
                return false;
            }
        }

        // E-mail 检查
        if (is_register|| (f.mb_email.defaultValue != f.mb_email.value)) {
            const msg = reg_mb_email_check();
            if (msg) {
                alert(msg);
                f.reg_mb_email.select();
                return false;
            }
        }


        return true;
    }

    function flogin_submit(f) {
        const mb_id = $.trim($(f).find("input[name=mb_id]").val()),
            mb_password = $.trim($(f).find("input[name=mb_password]").val());

        if (!mb_id || !mb_password) {
            return false;
        }

        return true;
    }
</script>

<!-- } 输入成员信息/修正结束 -->
{% endblock content %}